package com.ccrfid.rmc6.resource.sys;

import com.ccrfid.rmc6.appconfig.auth.Secured;
import com.ccrfid.rmc6.entity.sys.AppModuleEntity;
import com.ccrfid.rmc6.resource.auth.pojo.UserPrincipal;
import com.ccrfid.rmc6.service.sys.AppModuleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.SecurityContext;
import java.util.List;

@Secured
@Path("app-modules")
@Produces(MediaType.APPLICATION_JSON)
public class AppModuleResource {
    private static final Logger logger = LoggerFactory.getLogger(AppModuleResource.class);
    @Context
    private SecurityContext securityContext;
    @Autowired
    private AppModuleService appModuleService;

    //获取某个用户可以看到的应用模块信息
    @GET
    public List<AppModuleEntity> getAppModules() {
        UserPrincipal userPrincipal = (UserPrincipal) securityContext.getUserPrincipal();
        return appModuleService.getAppModules(userPrincipal);
    }


}
